package com.ruoyi.job.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.erp.auto.domain.ErpAutoUnshelfProductConfig;
import com.ruoyi.auto.api.RemoteAutoUnShelfProductService;
import com.ruoyi.common.core.domain.R;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component("autoUnShelfProductTask")
public class AutoUnShelfProductTask {
    
    @Resource
    RemoteAutoUnShelfProductService remoteAutoUnShelfProductService;
    
    public void unShelfProduct() {
        
        R<Object> list = remoteAutoUnShelfProductService.getImplementList(null);
        if (list.getCode() == 200) {
            List<ErpAutoUnshelfProductConfig> configList = JSONArray.parseArray(JSONObject.toJSONString(list.getData()), ErpAutoUnshelfProductConfig.class);
            for (ErpAutoUnshelfProductConfig config : configList) {
                remoteAutoUnShelfProductService.unShelfProduct(config);
            }
        }
        
    }
}
